#include <iostream>
#include <memory>
using std::unique_ptr;
using std::cout;
using std::endl;


class Strategy{
public:
    virtual void execute()=0;
};

class Strategy_a:public Strategy{
public:
    void execute() override{
        cout << "exectute strategy a" << endl;
    }
};
class Strategy_b:public Strategy{
public:
    void execute() override{
        cout << "exectute strategy b" << endl;
    }
};

class Context{
public:
    Context():_pst(nullptr){};
    void setStrategy(Strategy * pst){
        _pst = pst;
    }
    void executeStrategy(){
        _pst->execute();
    }
private:
    Strategy * _pst;
};


void test(){
    unique_ptr<Strategy> str_a(new Strategy_a());
    unique_ptr<Strategy> str_b(new Strategy_b());

    Context context;
    context.setStrategy(str_a.get());
    context.executeStrategy();
    context.setStrategy(str_b.get());
    context.executeStrategy();
}

int main()
{


    test ();
    return 0;
}

